/*    */ package system.staros.sblock1;
/*    */ 
/*    */ import java.util.Iterator;
/*    */ import java.util.Map.Entry;
/*    */ 
/*    */ public class ForeachNode extends Node
/*    */ {
/*    */   private VariableNode onVariableNode;
/*    */   private Node asNode;
/*    */   private Node loopBody;
/*    */ 
/*    */   public ForeachNode(SourcePosition paramSourcePosition, VariableNode paramVariableNode, Node paramNode1, Node paramNode2)
/*    */   {
/* 39 */     super(paramSourcePosition);
/* 40 */     this.onVariableNode = paramVariableNode;
/* 41 */     this.asNode = paramNode1;
/* 42 */     this.loopBody = paramNode2;
/*    */   }
/*    */ 
/*    */   public ZemObject eval(Interpreter paramInterpreter)
/*    */   {
/* 47 */     ZemObject localZemObject1 = paramInterpreter.getVariable(this.onVariableNode.getName(), this.onVariableNode.getPosition());
/* 48 */     ZemObject localZemObject2 = null;
/*    */     Object localObject1;
/*    */     Object localObject2;
/*    */     Object localObject3;
/* 49 */     if ((localZemObject1 instanceof ZemArray)) {
/* 50 */       localObject1 = this.asNode.toString();
/* 51 */       for (localObject2 = ((ZemArray)localZemObject1).iterator(); ((Iterator)localObject2).hasNext(); ) { localObject3 = (ZemObject)((Iterator)localObject2).next();
/* 52 */         paramInterpreter.setVariable((String)localObject1, (ZemObject)localObject3);
/* 53 */         localZemObject2 = this.loopBody.eval(paramInterpreter);
/*    */       }
/* 55 */       return localZemObject2;
/* 56 */     }if ((localZemObject1 instanceof Dictionary)) {
/* 57 */       localObject1 = (DictionaryEntryNode)this.asNode;
/* 58 */       localObject2 = ((VariableNode)((DictionaryEntryNode)localObject1).getKey()).getName();
/* 59 */       localObject3 = ((VariableNode)((DictionaryEntryNode)localObject1).getValue()).getName();
/* 60 */       for (Map.Entry localEntry : (Dictionary)localZemObject1) {
/* 61 */         paramInterpreter.setVariable((String)localObject2, (ZemObject)localEntry.getKey());
/* 62 */         paramInterpreter.setVariable((String)localObject3, (ZemObject)localEntry.getValue());
/* 63 */         localZemObject2 = this.loopBody.eval(paramInterpreter);
/*    */       }
/* 65 */       return localZemObject2;
/*    */     }
/* 67 */     throw new InvalidTypeException("foreach expects an array or dictionary.", this.onVariableNode.getPosition());
/*    */   }
/*    */ 
/*    */   public String toString()
/*    */   {
/* 72 */     StringBuilder localStringBuilder = new StringBuilder();
/* 73 */     localStringBuilder.append('(');
/* 74 */     localStringBuilder.append("foreach ");
/* 75 */     localStringBuilder.append(this.onVariableNode);
/* 76 */     localStringBuilder.append(' ');
/* 77 */     localStringBuilder.append(this.asNode);
/* 78 */     localStringBuilder.append(' ');
/* 79 */     localStringBuilder.append(this.loopBody);
/* 80 */     localStringBuilder.append(')');
/* 81 */     return localStringBuilder.toString();
/*    */   }
/*    */ }

/* Location:           D:\Марк\!IMPORTANT\staros\archive\version-2.260.zip
 * Qualified Name:     system.staros.sblock1.ForeachNode
 * JD-Core Version:    0.6.1
 */